import java.util.List;
import java.util.ArrayList;
import java.util.Scanner;
/*以空格为分隔符，将line转换为List<String>*/

public class ListDelete_pta541 {

	public static List<String> convertStringToList(String line)  {
		   List<String> list=new ArrayList<String> ();	
		    /*Scanner sc=new Scanner(line);
		    while(sc.hasNext()){
		    	list.add(sc.next());
		    }
		    sc.close();
		    return list;*/
		   String[] str=line.split(" ");
		   for (int i = 0; i < str.length; i++) {
		   	if(!str[i].equals("")){
		   		list.add(str[i]);
		   	}
		   }
		   return list;

	}
	/*在list中移除掉以与str内容相同的元素*/
	public static void remove(List<String> list, String str){
			while(list.contains(str))
				list.remove(str);
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()){
            List<String> list = convertStringToList(sc.nextLine());
            System.out.println(list);
            String word = sc.nextLine();
            remove(list,word);
            System.out.println(list);
        }
        sc.close();

	}

}

/*String[] str=line.split(" ");
for (int i = 0; i < str.length; i++) {
	if(!str[i].equals("")){
		list.add(str[i]);
	}
}
return list;*/
